<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('分销积分列表')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>



                                                    <li>
                                                        <label>提现标识：</label>
                                                        <select name="cashState" th:with="type=${@dict.getType('cash_type')}">
                                                            <option value="">所有</option>
                                                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                                        </select>
                                                    </li>
                        <!--                            <li>-->
                        <!--                                <label>接洽时间：</label>-->
                        <!--                                <input type="text" class="time-input" placeholder="请选择接洽时间" name="acceptDate"/>-->
                        <!--                            </li>-->
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

                    <div class="btn-group-sm" id="toolbar" role="group">
                        <a class="btn btn-warning" onclick="cash()" shiro:hasPermission="system:account:cash">
                            <i class="fa fa-plus"></i> 我要提现
                        </a>

                    </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">

    var ratingDatas = [[${@dict.getType('sys_user_rating')}]];
    var accountTypeDatas = [[${@dict.getType('account_type')}]];
    var cashDatas = [[${@dict.getType('cash_type')}]];
    var prefix = ctx + "system/account";

    $(function() {
        var options = {
            url: prefix + "/scoringList",
            showFooter: true,
            showToggle: false,
            showColumns: false,
            modalName: "分销积分提现",
            footerStyle: footerStyle,
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: 'id',
                    visible: false
                },
                {
                    field: 'userId',
                    title: '用户ID',
                    visible: false
                },
                {
                    field: 'userName',
                    title: '用户名'
                },
                {
                    field: 'reInfiId',
                    title: '预约开户记录ID',
                    visible: false
                },
                {
                    field : 'bonus',
                    title : '积分',
                    footerFormatter:function (value) {
                        var sumBalance = 0;
                        for (var i in value) {
                            sumBalance += parseFloat(value[i].bonus);
                        }
                        return "总金额：" + sumBalance;
                    }
                },


                {
                    field: 'reNumber',
                    title: '预约编号'
                },
                {
                    field: 'ratingId',
                    title: '分销用户id',
                    visible: false
                },
                {
                    field: 'ratingName',
                    title: '分销用户名'
                },
                {
                    field: 'rating',
                    title: '分销等级',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(ratingDatas, value);
                    }
                },
                {
                    field: 'company',
                    title: '预约企业名称'
                },
                {
                    field: 'accountType',
                    title: '账户性质',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(accountTypeDatas, value);
                    }
                },
                {
                    field: 'acceptDate',
                    title: '接洽时间'
                } , {
                    field: 'cashState',
                    title: '提现标识',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(cashDatas, value);
                    }
                }


            ]
        };
        $.table.init(options);
    });

    function footerStyle(column) {
        return {
//         	    userBalance: {
//         	        classes: 'class'
//         	    },
            bonus: {
                css: { color: 'red', 'font-weight': 'normal' }
            }
        }[column.field]
    }

     function cash() {
        table.set();
        var rows = $.common.isEmpty(table.options.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns(table.options.uniqueId);
        if (rows.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        $.modal.confirm("确认要提现选中的" + rows.length + "条数据吗?", function() {
            var url = ctx + "system/account/cash";
            var data = { "ids": rows.join() };

            $.operate.submit(url, "post", "json", data);
        });
    }
</script>
</body>
</html>